function fieldsChecker(loginId, passwordId, emailId, loginErrorId, passwordErrorId, emailErrorId) {
    this.$login = $("#"+loginId);
    this.$password = $("#"+passwordId);
    this.$email = $("#"+emailId);
    this.$loginError = $("#"+loginErrorId);
    this.$passwordError = $("#"+passwordErrorId);
    this.$emailError = $("#"+emailErrorId);
}

fieldsChecker.prototype = {
    checkFields: function() {
        var loginError = false;
        var passwordError = false;
        var emailError = false;

        if($.trim(this.$login.val()) == "" || $.trim(this.$login.val()).length < 4) {
            loginError = true;
            this.$loginError.show("slow");
        } else {
            loginError = false;
            this.$loginError.hide("slow");
        }

        if($.trim(this.$password.val()) == "" || $.trim(this.$password.val()).length < 4) {
            passwordError = true;
            this.$passwordError.show("slow");
        } else {
            passwordError = false;
            this.$passwordError.hide("slow");
        }

        if($.trim(this.$email.val()) == "" || !this.validateMail(this.$email.val())) {
            emailError = true;
            this.$emailError.show("slow");
        } else {
            emailError = false;
            this.$emailError.hide("slow");
        }

        if(!loginError && !passwordError && !emailError) {
            return true;
        }
        return false;
    },
    
    validateMail: function(mail) {
        var regExp = /^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i;
        if (!regExp.test($.trim(mail))) {
            return false;
        }
        return true;
    },
    
    clearAll: function() {
        this.$login.val("");
        this.$password.val("");
        this.$email.val("");
    }
}